home *** CD-ROM | disk | FTP | other *** search
/ Imagine the Universe (9th Edition) / Imagine the Universe 9 - Disc 1.iso / pc / imagine / YBA / HTCas-size / javascript / lightcurve.js < prev    next >
Text File  |  2003-01-12  |  1KB  |  50 lines

  1. position1 = "Blank";
  2. position2 = "Blank";
  3. position3 = "Blank";
  4. position4 = "Blank";
  5.  
  6. function testButton(form) {
  7.     for (Count = 0; Count < 4; Count++) {
  8.         if (form.position1[Count].checked)
  9.     position1 = Count;
  10.     if (form.position2[Count].checked)
  11.     position2 = Count;
  12.     if (form.position3[Count].checked)
  13.     position3 = Count;
  14.     if (form.position4[Count].checked)
  15.     position4 = Count;
  16.     }
  17.     
  18.     RightAnswer1 = 0;
  19.     RightAnswer2 = 1;
  20.     RightAnswer3 = 2;
  21.     RightAnswer4 = 3;
  22.     
  23.     NumberCorrect = 0;
  24.     CorrectAnswerPage = './htcas-xray2.html';
  25.     WrongAnswerPage = './lightcurve_match2.html';
  26.     
  27.     if (position1 == RightAnswer1) {
  28.         NumberCorrect++;
  29.     }
  30.     if (position2 == RightAnswer2) {
  31.         NumberCorrect++;
  32.     }
  33.     if (position3 == RightAnswer3) {
  34.         NumberCorrect++;
  35.     }
  36.     if (position4 == RightAnswer4) {
  37.         NumberCorrect++;
  38.     }
  39.  
  40.     if (NumberCorrect == 4) {
  41.     alert ("Congratulations you got them all!");
  42.     location = CorrectAnswerPage;
  43.     }
  44.     else {
  45.     alert ("You answered " +NumberCorrect + " out of 4 questions correctly.  Keep trying!");
  46.     }
  47. }
  48.  
  49.     
  50.